package view;

import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import model.User;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * description:
 *
 * @author wht
 * @createDate 2022/12/31 20:02
 */
public class ErrorView {

    public ErrorView(String errMsg) {
        init(errMsg);
    }

    void init(String errMsg) {
        Stage stage = new Stage();
        Label label = new Label(errMsg);

        Button sureButton = new Button("确定");
        HBox labelBox = new HBox();
        HBox sureButtonBox = new HBox();
        VBox mainBox = new VBox();

        labelBox.getChildren().add(label);
        labelBox.setAlignment(Pos.CENTER);
        labelBox.setSpacing(20);
        sureButtonBox.getChildren().add(sureButton);
        sureButtonBox.setAlignment(Pos.CENTER);
        sureButtonBox.setSpacing(20);
        sureButton.setAlignment(Pos.BASELINE_RIGHT);

        mainBox.setAlignment(Pos.CENTER);
        mainBox.setSpacing(20);
        mainBox.getChildren().addAll(labelBox,sureButtonBox);

        stage.setScene(new Scene(mainBox,400,250));
        stage.show();

        sureButton.setOnAction(a -> {
            stage.close();
        });
    }
}
